package cheesymock;

import java.lang.reflect.*;
import static cheesymock.MethodUtil.*;

public class MissingMethod extends Validator {
    
	@Override
	public void invocation(Method method, Object[] arguments) {
		if (delegate != null) {
			try {
				try {
					resolveMethod(method, arguments, delegate);
					return;
				}
				catch (NoSuchMethodException e) {
				}
				try {
					resolveProperty(method, arguments, delegate);
					return;
				}
				catch (NoSuchFieldException e) {
				}
				throw new UnsupportedOperationException("Method " + methodName(method, arguments)
						+ " called, but no such method was defined in the delegate object.");
			}
			catch (Exception e) {
				throw toRuntimeException(e);
			}
		}
	}
}